package com.tencent.externalstoragebar.evetntools;

import android.util.Log;

//一个手指的触摸事件
public class OneEvent {

    //常量
    public static final int IS_NOTHING=0;//没有事件
    public static final int IS_DOWN=1;//按下
    public static final int IS_UP=2;//抬起
    public static final int IS_MOVE=3;//滑动

    //常量的意义
    public static final String[] eventArr={
            "没有事件",
            "按下",
            "抬起",
            "滑动"
    };

    //下面是int类型的各种数据
    private int x=0;
    private int y=0;
    private int id=0;//手指id
    private int index=0;//槽位
    private int event=IS_NOTHING;//当前状态(按下,抬起,滑动,没有)

    //构造方法
    public OneEvent() {
        this.x=0;
        this.y=0;
        this.id=0;
        this.event=IS_NOTHING;
    }

    //各种set和get方法,判断值是否合理
    public int getX() {
        return x;
    }

    public void setX(int x) {
        if (x<0){
            setError(this.x,x);
            return;
        }
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        if (y<0){
            setError(this.y,y);
            return;
        }
        this.y = y;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        /*if (id<0||id>=10){
            setError(this.id,id);
            return;
        }*/
        //Log.d("acl","设置id");
        this.id = id;
    }

    public int getEvent() {
        return event;
    }

    public void setEvent(int event) {
        if (event<IS_NOTHING||event>IS_MOVE){
            setError(this.event,event);
            return;
        }
        this.event = event;
    }

    public OneEvent(int x, int y, int id, int index, int event) {
        this.x = x;
        this.y = y;
        this.id = id;
        this.index = index;
        this.event = event;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    //如果不合理,怎么处理
    public void setError(int unadorned,int set){
        Log.e("acl",unadorned+"不可以被设置为"+set);
    }
}
